<template>
	<view>
		<u-navbar :background="navObj" :is-back="false" :is-fixed="true" height="89" width="100%">
			<div class="title">消息中心</div>

			<view class="left-box" @tap="onClickLeft">
				<u-icon name="arrow-left" size="40" color="#FFF"></u-icon>
			</view>
		
		</u-navbar>

		<div class="memulist">
			<div class="memuitem" v-for="items in list" :key="items.id" @click="handleGoDetail(items.id)">
				<span class="memutext">{{items.title}}</span>
				<span class="memutime">{{items.createTime}}</span>
				<span class="memucontent">{{items.content}}</span>
			</div>
		</div>
	</view>
</template>

<script>
	import {
		messageHome
	} from '@/api/user.js'
	export default {
		data() {
			return {
				navObj: {
					backgroundColor: 'rgb(25, 189, 93)',
				},
				list: [],
				page: 1,
				limit: 10
			}
		},
		
		onReachBottom() {
			this.page = this.page + 1;
			this.getList()
		},
		methods: {
			onClickLeft() {
				uni.navigateBack();
			},
			
			

			getList(){
				messageHome({
					page: this.page,
					limit: this.limit
				}).then(res => {
					if (res.code == '000000') {
						this.list = [...this.list, ...res.data.list]
					}
				})
			},
			handleGoDetail(id) {
				console.log('123')
				uni.navigateTo({
				  url: `/pages/tabbar/user/messageDetail?id=${id}`,
				});
			},
		},
		mounted() {
		this.getList()
		}
	}
</script>

<style scoped>
	.title {
		position: absolute;
		top: 80rpx;
		left: 50%;
		transform: translateX(-50%);
		font-family: PingFang;
		font-weight: bold;
		font-size: 33rpx;
		color: #FFFFFF;

	}

	.memulist {
		width: 100%;
		/* margin: 100rpx 3%; */
		background: #fff;
		border-radius: 20rpx;
		box-shadow: 0 4rpx 24rpx 0 rgba($color: #f6f6f6, $alpha: 1);
		display: flex;
		flex-wrap: wrap;
		align-content: flex-start;
	}

	.memuitem {
		width: 100%;
		height: 147rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1px solid #f3f3f3;
		position: relative;
		margin-top: 20rpx;
	}

	.memutext {
		position: absolute;
		top: 37rpx;
		left: 21rpx;
		font-family: Adobe Heiti Std;
		font-weight: normal;
		font-size: 29rpx;
		color: #151F38;
	}
	
	.memutime {
		font-family: PingFang;
		font-weight: 500;
		font-size: 23rpx;
		color: #BCC3CF;
		position: absolute;top: 46rpx;right: 21rpx;
	}
	
	.memucontent {
		width: 443rpx;
		position: absolute;
		top: 86rpx;
		left: 21rpx;
		font-family: PingFang;
		font-weight: 500;
		font-size: 25rpx;
		color: #9AA1AD;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.left-box {
		padding-left: 41rpx;
	}
</style>
